<template>
  <div class="gooditem" @click="todetail(item.id)">
    <el-image
      :src="item.img"
      fit="contain"
      style="width: 100%; height: 360px"
    />
    <div class="goodinfo">
      <div class="goodmain">
        <div class="name">机型：{{ item.name }}</div>
        <div class="stock">库存：{{ item.stock }}</div>
      </div>
      <div class="goodbuy">
        <div class="price">￥{{ item.price }}</div>
        <el-button color="rgb(238, 86, 65)" round>查看详情</el-button>
      </div>
    </div>
  </div>
</template>
<script setup>
import { useRouter } from "vue-router";
const router = useRouter();
defineProps({
  item: {},
});
function todetail(id) {
  router.push({
    path: "detail",
    query: {
      id,
    },
  });
}
</script>
<style scoped>
.gooditem {
  width: 45%;
  background-color: #fff;
  border-radius: 20px;
  margin-bottom: 10px;
}
.gooditem img {
  border-radius: 20px;
}
.goodinfo {
  display: flex;
  justify-content: space-between;
  padding: 26px 30px;
}
.goodmain .name {
  font-size: 24px;
  line-height: 30px;
  font-weight: 700;
}
.goodmain .stock {
  margin-top: 6px;
  height: 20px;
  font-size: 16px;
  line-height: 20px;
  color: #000;
}
.goodbuy .price {
  font-size: 24px;
  color: rgb(238, 86, 65);
}
.el-button {
  color: #fff;
}
</style>
